<?php 
namespace app\common\controller;
use think\Controller;
use think\Request;
use think\Session;
use think\View;
use app\common\model\AdminLog;
/**
 * @Author: YeMiao
 * @Date:   2017-07-29 15:12:04
 * @Last Modified by:   YeMiao
 * @Last Modified time: 2017-11-04 14:33:41
 */

class Base extends Controller{	
	function __construct(){
		parent::__construct();
		// 强制返回系统入口
		$request = Request::instance();
		$action = $request->controller().'/'.$request->action();
		if($action != 'Index/index' && !$request->isPjax() && !$request->isPost()){
			cookie('to_url',$request->url());
      Header('Location:'.url('index/index'));
		}
		$log = new AdminLog();
		if(Session::has('user')){
			if(Session::get('group') != 0 || Session::get('state') == 0){				
				$log->add_log('登录失败！');
				Session::clear();
				$this->success('当前用户没有权限或用户被冻结,请与管理员核实!','login/index');
			}else{
				$time = time();
				if($time - Session::get('ontime') > 3600){
					$log->add_log('登录超时！');
					$this->success('登录超时','login/index');
				}else{
					Session::set('ontime',time());
				}			
			}
		}else{
			$this->success('请你先进行登录','login/index');
		}
	}
}

 ?>